#pragma once
#include <cstdio>
#include <cstdarg>
#include <ctime>

namespace ns_log
{
    #define DEBUG 0
    #define NORMAL 1
    #define WARNING 2
    #define ERROR 3
    #define FATAL 4

    static const char *gLevelMap[] = {
        "DEBUG",
        "NORMAL",
        "WARNING",
        "ERROR",
        "FATAL"};
    static void logMessage(int level, const char *format, ...)
    {
        time_t timeStamp = time(nullptr);
        char stdBuffer[1024];
        snprintf(stdBuffer, sizeof stdBuffer, "[%s] [%ld]", gLevelMap[level], timeStamp);

        va_list arg;
        va_start(arg, format);
        char usrBuffer[1024];
        vsnprintf(usrBuffer, sizeof stdBuffer, format, arg);
        va_end(arg);

        printf("%s %s\n", stdBuffer, usrBuffer);
    }
}